<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<!-- 
		Replace path to template, title, header and body
		with actual data.
	 -->
<ui:composition template="/template/template.xhtml">
	<ui:define name="pageTitle">Cadastro de Marcas</ui:define>
	<ui:define name="pageHeader">Marcas</ui:define>
	<ui:define name="body">
		<h1>Cadastro de Marcas</h1>
		<h:form id="edicao">
			<h:messages />

			<h:inputHidden value="#{marcaBean.marca.marca}" />

			<h:panelGrid columns="2">
				<h:outputLabel value="Nome:" />
				<h:inputText id="nomeMarca" value="#{marcaBean.marca.nome}" />

			
			</h:panelGrid>
			<h:commandButton value="Salvar" action="#{marcaBean.salvar}" />
			<h:commandButton value="Nova Marca" action="#{marcaBean.novo}" />

		</h:form>
		<h:messages />
		<h:form id="lista">
			<h:dataTable value="#{marcaBean.lista}" var="marca" rules="rows"
				cellpadding="5">
				<f:facet name="header">Listagem de marcas</f:facet>
				<f:facet name="footer">Final da Listagem</f:facet>
				<h:column>
					<f:facet name="header">Estado</f:facet>
					<h:commandLink action="#{marcaBean.ativar}">
						<h:graphicImage library="imagens"
							name="marca_ativo_#{marca.flagAtiva}.png" style="borde:0" />
						<f:setPropertyActionListener target="#{marcaBean.marca}"
							value="#{marca}" />
					</h:commandLink>
				</h:column>
				<h:column>
					<f:facet name="header">Nome</f:facet>
                        #{marca.nome}
                        </h:column>
				
				<h:column>
					<f:facet name="header">Ações</f:facet>
					<h:commandLink action="#{marcaBean.excluir}"
						onclick="if (!confirm('Deseja realmente excluir a marca #{marca.nome}?')) return false;">
						<h:graphicImage library="imagens" name="remove.png" />
						<f:setPropertyActionListener target="#{marcaBean.marca}"
							value="#{marca}" />
					</h:commandLink>


					<h:commandLink action="#{marcaBean.editar}" value="">
						<h:graphicImage library="imagens" name="edita.jpg" style="borde:0" />
						<f:setPropertyActionListener target="#{marcaBean.marca}"
							value="#{marca}" />
					</h:commandLink>
				</h:column>
			</h:dataTable>


		</h:form>

	</ui:define>
</ui:composition>

</html>